package com.itheima.controller;

import com.itheima.config.GoodsFeginClient;
import com.itheima.domain.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Administrator
 */

@RestController
@RequestMapping("/goods")
public class GoodsController {


//    @Autowired
//    private RestTemplate restTemplate; //测试用例

    @Autowired
    private GoodsFeginClient goodsFeginClient;


    @RequestMapping("/findOne/{id}")
    public Goods findOne(@PathVariable int id) {

//        //nacos通过启用注册到注册中心的服务名称来代替ip和端口来查询服务 不区分大小写
//        String url="http://SpringCloud-nacos-provider/goods/findOne/"+id;
//        Goods goods = restTemplate.getForObject(url, Goods.class); //临时注释
        Goods goods = goodsFeginClient.findOne(id);

        return goods;
    }

}
